package de.devisnik.eidle.mine;

import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;

public class MinesPreferencePage extends FieldEditorPreferencePage implements
		IWorkbenchPreferencePage {

	public MinesPreferencePage() {
		super("Minesweeper", GRID);
		setPreferenceStore(MineActivator.getDefault().getPreferenceStore());
	}

	protected void createFieldEditors() {
		final IntegerFieldEditor widthEditor = createIntegerEditor(
				MinesPreferences.KEY_FIELD_WIDTH, "field width");
		widthEditor.setValidRange(8, 64);
		addField(widthEditor);
		final IntegerFieldEditor heightEditor = createIntegerEditor(
				MinesPreferences.KEY_FIELD_HEIGHT, "field height");
		heightEditor.setValidRange(8, 64);

		final IntegerFieldEditor bombsEditor = createIntegerEditor(
				MinesPreferences.KEY_FIELD_BOMBS, "Bombs");
		bombsEditor.setValidRange(10, 999);
	}

	private IntegerFieldEditor createIntegerEditor(final String key,
			final String label) {
		final IntegerFieldEditor heightEditor = new IntegerFieldEditor(key,
				label, getFieldEditorParent());
		addField(heightEditor);
		return heightEditor;
	}

	public void init(final IWorkbench workbench) {

	}

}
